
package net.swa.dewei.beans.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

/**
 * 商家信息
 * @author junyu
 *
 */
@Entity
@Table(name = "t_Merchants")
public class Merchants implements Comparable<Merchants>
{
    //PK
    private Long id;

    /**名称**/
    private String name;

    //联系人
    private String lxr;

    //联系电话
    private String lxrTel;

    //商家类型
    private String type;

    //商家编号
    private String no;

    //微信号？
    private String wxNo;

    //微信id
    private String wxid;

    //商家的微信昵称，不做数据库映射
    private String wxNick;

    //活动开始时间
    private String actiBeginTime;

    //活动结束时间
    private String actiEndTime;

    //使用规则
    private String useRules;

    private String allowTime;

    //不可以使用日期
    private String invaliDates;

    //关键字
    private String keyWords;

    //活动协议附件url
    private String actiAtt;

    /**详细说明**/
    private String detailInfo;

    /**经度**/
    private Double latitude;

    /**维度**/
    private Double longitude;

    /**地址**/
    private String address;

    /**省**/
    private String province;

    /**市*/
    private String city;

    /**县**/
    private String town;

    /**服务站id*/
    private Long fuwuzhanId;

    //服务站名称，不做数据库映射
    private String fwzName;

    /**店面图片**/
    private String imageUrl;

    /**创建时间**/
    private String crateDate;

    /**更新时间**/
    private String updateDate;

    /**状态，
    '0' : '保存',
    '1' : '提交',
    '2' : '审核通过',
    '3' : '审核驳回',
    '4' : '下架'
     */
    private String status;

    //是否被删除的数据
    private boolean deldata;

    //原因（不通过的原因）
    private String reason;

    //下架原因
    private String xiajiaReason;

    /***距离目标点距离，不做数据库映射**/
    private String distance;

    /***距离目标点距离,做比较使用,不做数据库映射**/
    private Double doubleDistance;

    /**是否推荐店面（不做实体映射）*/
    private boolean tuijian;

    @GenericGenerator(name = "generator", strategy = "native")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "id", unique = true, nullable = false)
    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public Double getLatitude()
    {
        return latitude;
    }

    public void setLatitude(Double latitude)
    {
        this.latitude = latitude;
    }

    public Double getLongitude()
    {
        return longitude;
    }

    public void setLongitude(Double longitude)
    {
        this.longitude = longitude;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    public String getProvince()
    {
        return province;
    }

    public void setProvince(String province)
    {
        this.province = province;
    }

    public String getCity()
    {
        return city;
    }

    public void setCity(String city)
    {
        this.city = city;
    }

    public String getTown()
    {
        return town;
    }

    public void setTown(String town)
    {
        this.town = town;
    }

    public Long getFuwuzhanId()
    {
        return fuwuzhanId;
    }

    public void setFuwuzhanId(Long fuwuzhanId)
    {
        this.fuwuzhanId = fuwuzhanId;
    }

    public String getImageUrl()
    {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl)
    {
        this.imageUrl = imageUrl;
    }

    public String getDetailInfo()
    {
        return detailInfo;
    }

    public void setDetailInfo(String detailInfo)
    {
        this.detailInfo = detailInfo;
    }

    public String getCrateDate()
    {
        return crateDate;
    }

    public void setCrateDate(String crateDate)
    {
        this.crateDate = crateDate;
    }

    public String getUpdateDate()
    {
        return updateDate;
    }

    public void setUpdateDate(String updateDate)
    {
        this.updateDate = updateDate;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    @Transient
    public String getFwzName()
    {
        return fwzName;
    }

    public void setFwzName(String fwzName)
    {
        this.fwzName = fwzName;
    }

    public String getLxr()
    {
        return lxr;
    }

    public void setLxr(String lxr)
    {
        this.lxr = lxr;
    }

    public String getLxrTel()
    {
        return lxrTel;
    }

    public void setLxrTel(String lxrTel)
    {
        this.lxrTel = lxrTel;
    }

    public boolean isDeldata()
    {
        return deldata;
    }

    public void setDeldata(boolean deldata)
    {
        this.deldata = deldata;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public String getNo()
    {
        return no;
    }

    public void setNo(String no)
    {
        this.no = no;
    }

    public String getWxid()
    {
        return wxid;
    }

    public void setWxid(String wxid)
    {
        this.wxid = wxid;
    }

    public String getActiBeginTime()
    {
        return actiBeginTime;
    }

    public void setActiBeginTime(String actiBeginTime)
    {
        this.actiBeginTime = actiBeginTime;
    }

    public String getActiEndTime()
    {
        return actiEndTime;
    }

    public void setActiEndTime(String actiEndTime)
    {
        this.actiEndTime = actiEndTime;
    }

    public String getUseRules()
    {
        return useRules;
    }

    public void setUseRules(String useRules)
    {
        this.useRules = useRules;
    }

    public String getInvaliDates()
    {
        return invaliDates;
    }

    public void setInvaliDates(String invaliDates)
    {
        this.invaliDates = invaliDates;
    }

    public String getKeyWords()
    {
        return keyWords;
    }

    public void setKeyWords(String keyWords)
    {
        this.keyWords = keyWords;
    }

    public String getActiAtt()
    {
        return actiAtt;
    }

    public void setActiAtt(String actiAtt)
    {
        this.actiAtt = actiAtt;
    }

    @Transient
    public String getWxNick()
    {
        return wxNick;
    }

    public void setWxNick(String wxNick)
    {
        this.wxNick = wxNick;
    }

    public String getReason()
    {
        return reason;
    }

    public void setReason(String reason)
    {
        this.reason = reason;
    }

    public String getAllowTime()
    {
        return allowTime;
    }

    public void setAllowTime(String allowTime)
    {
        this.allowTime = allowTime;
    }

    public String getWxNo()
    {
        return wxNo;
    }

    public void setWxNo(String wxNo)
    {
        this.wxNo = wxNo;
    }

    public String getXiajiaReason()
    {
        return xiajiaReason;
    }

    public void setXiajiaReason(String xiajiaReason)
    {
        this.xiajiaReason = xiajiaReason;
    }

    @Transient
    public String getDistance()
    {
        return distance;
    }

    public void setDistance(String distance)
    {
        this.distance = distance;
    }

    @Transient
    public Double getDoubleDistance()
    {
        return doubleDistance;
    }

    public void setDoubleDistance(Double doubleDistance)
    {
        this.doubleDistance = doubleDistance;
    }

    @Transient
    public boolean isTuijian()
    {
        return tuijian;
    }

    public void setTuijian(boolean tuijian)
    {
        this.tuijian = tuijian;
    }

    @Override
    public int compareTo(Merchants o)
    {
        if (null == this.doubleDistance && null != o.getDoubleDistance())
        {
            return 1;
        }
        else if (null != this.doubleDistance && null == o.getDoubleDistance())
        {
            return -1;
        }
        else if (null != this.doubleDistance && null != o.getDoubleDistance())
        {
            if (this.doubleDistance > o.getDoubleDistance())
            {
                return 1;
            }
            if (this.doubleDistance < o.getDoubleDistance())
            {
                return -1;
            }
            return 0;
        }
        else
        {
            return 0;
        }
    }

}
